home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / text / misc / mpage.lha / mpage / sample.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-07-25  |  2.7 KB  |  150 lines

  1. /*
  2.  * sample.c
  3.  */
  4.  
  5. /*
  6.  * Copyright (c) 1994-1997 Marcel J.E. Mol, The Netherlands
  7.  *                    marcel@mesa.nl
  8.  */
  9.  
  10.  
  11. # include "mpage.h"
  12.  
  13.  
  14. /*
  15.  * Function Declarations
  16.  */
  17. static void do_sample();
  18. static void urshow();
  19. static void lrshow();
  20. static void ulshow();
  21. static void llshow();
  22. static void box();
  23.  
  24. int
  25. main(argc, argv)
  26.  int argc;
  27.  char **argv;
  28. {
  29.     int currarg;
  30.  
  31.     /*
  32.      * examine the environment for PRINTER and MPAGE environment variables
  33.      */
  34.     if ((currarg = do_env()) == 0) {
  35.         usage(currarg);
  36.         exit(1);
  37.     }
  38.         
  39.     if ((currarg = do_args(argc, argv, 0)) < 0) {
  40.         usage(currarg);
  41.         exit(1);
  42.     }
  43.  
  44.     do_sample();
  45.  
  46.         exit(0);
  47. }
  48.  
  49.  
  50.  
  51. static void
  52. do_sample()
  53. {
  54.     printf("%%!PS-mpage-layout\n");
  55.     printf("/Courier findfont 8 scalefont setfont\n");
  56.     printf("0 setlinewidth\n");
  57.  
  58.     outline_8(stdout);
  59.  
  60.     urshow(xbase1(), ybase1());
  61.     urshow(xbase1(), ybase2());
  62.     urshow(xbase1(), ybase3());
  63.     urshow(xbase1(), ybase4());
  64.     lrshow(xbase1(), ytop1());
  65.     lrshow(xbase1(), ytop2());
  66.     lrshow(xbase1(), ytop3());
  67.     lrshow(xbase1(), ytop4());
  68.     ulshow(xbase1()+xwid2(), ybase1());
  69.     ulshow(xbase1()+xwid2(), ybase2());
  70.     ulshow(xbase1()+xwid2(), ybase3());
  71.     ulshow(xbase1()+xwid2(), ybase4());
  72.     llshow(xbase1()+xwid2(), ytop1());
  73.     llshow(xbase1()+xwid2(), ytop2());
  74.     llshow(xbase1()+xwid2(), ytop3());
  75.     llshow(xbase1()+xwid2(), ytop4());
  76.  
  77.     urshow(xbase2(), ybase1());
  78.     urshow(xbase2(), ybase2());
  79.     urshow(xbase2(), ybase3());
  80.     urshow(xbase2(), ybase4());
  81.     lrshow(xbase2(), ytop1());
  82.     lrshow(xbase2(), ytop2());
  83.     lrshow(xbase2(), ytop3());
  84.     lrshow(xbase2(), ytop4());
  85.     ulshow(xbase2()+xwid2(), ybase1());
  86.     ulshow(xbase2()+xwid2(), ybase2());
  87.     ulshow(xbase2()+xwid2(), ybase3());
  88.     ulshow(xbase2()+xwid2(), ybase4());
  89.     llshow(xbase2()+xwid2(), ytop1());
  90.     llshow(xbase2()+xwid2(), ytop2());
  91.     llshow(xbase2()+xwid2(), ytop3());
  92.     llshow(xbase2()+xwid2(), ytop4());
  93.     printf("showpage\n");
  94.  
  95.         return;
  96. }
  97.  
  98.  
  99.  
  100. static void
  101. urshow(int x, int y)
  102. {
  103.  
  104.     printf("%%- point %d,%d\n", x, y);
  105.     box(x, y);
  106.     printf("\t%d %d moveto (%d,%d) show\n", x+2, y+2, x, y);
  107. }
  108.  
  109.  
  110.  
  111. static void
  112. lrshow(int x, int y)
  113. {
  114.     printf("%%- point %d,%d\n", x, y);
  115.     box(x, y);
  116.     printf("\t%d %d moveto (%d,%d) show\n", x+2, y-6, x, y);
  117. }
  118.  
  119.  
  120.  
  121. static void
  122. ulshow(int x, int y)
  123. {
  124.     printf("%%- point %d,%d\n", x, y);
  125.     box(x, y);
  126.     printf("\t%d %d moveto\n", x-2, y+2);
  127.     printf("\t(%d,%d) dup stringwidth pop -1 mul 0 rmoveto show\n", x, y);
  128. }
  129.  
  130.  
  131.  
  132. static void
  133. llshow(int x, int y)
  134. {
  135.     printf("%%- point %d,%d\n", x, y);
  136.     box(x, y);
  137.     printf("\t%d %d moveto\n", x-2, y-6);
  138.     printf("\t(%d,%d) dup stringwidth pop -1 mul 0 rmoveto show\n", x, y);
  139. }
  140.  
  141.  
  142. static void
  143. box(int x, int y)
  144. {
  145.     printf("\t%d %d moveto %d %d lineto\n", x-1, y, x+1, y);
  146.     printf("\t%d %d moveto %d %d lineto\n", x, y-1, x, y+1);
  147.     printf("\tstroke\n");
  148. }
  149.  
  150.